<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./vue.js"></script>
</head>

<body>
  <div id="app">
    {{time | formattime('yyyy') | prefix }}
  </div>
  <script>


    Vue.filter('formattime', function (val, params) {
      console.log(arguments)
      if (params === 'yyyy') {
        return val.substring(0, 4);
      }

    })


    Vue.filter('prefix', function (val, params) {
      return '今年是：' + val + '年'
    })

    var vm = new Vue({
      el: "#app",
      data: {
        time: '2020-07-24 10:20'
      },
      mounted() {
      }
    })

  </script>
</body>

</html>